<%--
    Document   : search
    Created on : Jul 1, 2011, 9:00:25 AM
    Author     : PhongLK60473
--%>

<%@page import="Object.BookProperties.Type"%>
<%@page import="Object.BookProperties.Author"%>
<%@page import="Object.Page"%>
<%@page import="Object.Order"%>
<%@page import="Object.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">       
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <style type="" >
            @import url("style/style.css");
            @import url("style/manageaccounts.style.css");
        </style>
    </head>
    <body>
        <%@include file="header.jsp" %>
        <%
                    if (!user.isAdmin()) {
                        response.sendRedirect("UserController");
                    }
        %>
        <div id="page">

        <% if(Page.isMessage(request)){ %>
            <div class="message"><%= Page.getMessage(request) %></div>
        <% } %>
        <h1>User management</h1>

        <%

            User[] users = User.getAllUsers();
        %>

        <div id="search-result">
            <table border="1" class="accounts">
                <thead>
                    <tr class="title">
                        <th class="Id">Id</th>
                        <th class="Username">Username</th>
                        <th class="Role">Role</th>
                        <th class="Active">Active</th>
                        <th class="Action">Action</th>
                    </tr>
                </thead>
                <tbody>
                    <%
                    for(int i=0;i<users.length;i++){
                        User u=(User) users[i];
                    %>
                    <tr class="data">
                        <td class="Id">
                            <%= u.getId() %>
                        </td>
                        <td class="Username">
                            <%= u.getUsername() %>
                        </td>
                        <td class="Role">
                            <%= u.getRoles() %>
                        </td>
                        <td class="Active">
                            <%= u.isActive() %>
                        </td>
                        <td class="Action">
                            <%if(u.isActive()){ %>
                                <a title="Deactive user <%= u.getUsername() %>"
                                    href="ManagerController?action=DeactiveUser
&userid=<%= u.getId() %>">
                                    <img src="images/deactive_user.gif"/>
                                </a>
                            <%}else{%>
                                <a title="Active user <%= u.getUsername() %>"
                                    href="ManagerController?action=ActiveUser
&userid=<%= u.getId() %>">
                                    <img src="images/active_user.png"/>
                                </a>
                            <%}%>
                        </td>
                    </tr>
                    <%
                    }
                    %>
                </tbody>
            </table>
        </div>
        </div>
        <script>
            
        </script>
    </body>
</html>
